package com.fjnu.teaching;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @Configuration:   springconfig_applicaiton_context.xml
 */
@Configuration
@ComponentScan(basePackages = "com.fjnu.teaching")
public class SpringConfig {

    @Value("${mysql.driver}")
    private String driver ;
    @Value("${mysql.url}")
    private String url ;
    @Value("${mysql.user}")
    private String user ;
    @Value("${mysql.password}")
    private String password ;


    @Bean
    public Connection connection() {

        try {
            Class.forName(driver) ;
            return DriverManager.getConnection(url,user,password) ;


        }catch (Exception e) {

        }


        return null ;
    }

}
